package songZhao.MinaDemo.SessionAttribute;

import java.io.IOException;
import java.net.InetSocketAddress;
import java.nio.charset.Charset;

import org.apache.mina.core.service.IoAcceptor;
import org.apache.mina.core.session.IdleStatus;
import org.apache.mina.filter.codec.ProtocolCodecFilter;
import org.apache.mina.filter.codec.textline.LineDelimiter;
import org.apache.mina.filter.codec.textline.TextLineCodecFactory;
import org.apache.mina.transport.socket.nio.NioSocketAcceptor;
/**
 * 关键Attribute的内容再handler中,因为handler中操作session
 * @author Administrator
 *
 */
public class AttributeDemoServer {
	public static void main(String[] args) throws IOException {

		IoAcceptor acceptor = new NioSocketAcceptor();
		acceptor.getSessionConfig().setReadBufferSize(1024);
		acceptor.getSessionConfig().setIdleTime(IdleStatus.BOTH_IDLE, 5);
		acceptor.getFilterChain().addLast("telnet test",
				new ProtocolCodecFilter(new TextLineCodecFactory(Charset.forName("utf-8"),
						LineDelimiter.WINDOWS.getValue(), LineDelimiter.WINDOWS.getValue())));
		acceptor.setHandler(new AttributeDemoHandler());
		acceptor.bind(new InetSocketAddress("127.0.0.1", 10001));
	}
}
